#include "baseinsparseclass.h"

BaseInsParseClass::BaseInsParseClass()
{

}

int BaseInsParseClass::setDefaultCoord(int tool, int user)
{
    defaultToolCoordNumber=tool;
    defaultUserCoordNumber=user;
    return 1;
}



int BaseInsParseClass::transProgramStructToString(Program &outputProgram, QStringList &cmdStrListOut)
{
    cmdStrListOut.clear();

    for(int i=0;i<outputProgram.size();i++)
    {
        QString tmpStr;
        switch (outputProgram[i].type) {
        case MOTION:
        {
            switch (outputProgram[i].motion.motionFormat)
            {
            case E_MOTION_J:
                tmpStr="J P[";
                break;
            case E_MOTION_L:
                tmpStr="L P[";
                break;
            case E_MOTION_C:
                tmpStr="C P[";
                tmpStr+=QString::number(outputProgram[i].motion.p)+"] ";
                break;
            case E_MOTION_C2:
                tmpStr=" P[";
                break;
            case E_MOTION_A:
                tmpStr="A P[";
                break;
            default:
                break;
            }

            if(E_MOTION_C!=outputProgram[i].motion.motionFormat)
            {
                tmpStr+=QString::number(outputProgram[i].motion.p)+"] "+QString::number(outputProgram[i].motion.rate)
                        +"% ";
                if(0==outputProgram[i].motion.cnt)
                {
                    tmpStr+="FINE;";
                }
                else
                {
                    tmpStr+="CNT"+QString::number(outputProgram[i].motion.cnt)+" ; ";
                }
            }

        }

            break;
        default:
            qDebug()<<"transProgramStructToString errork,unsupport type"<<outputProgram[i].type;
            break;
        }

        cmdStrListOut.append(tmpStr);
    }
}
